import { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
import {beforeCreate} from "@adonisjs/lucid/build/src/Orm/Decorators";
import uuid from 'uuid-v4'
export default class Deliver extends BaseModel {
  public static table = 'tb_deliver'
  @column({ isPrimary: true })
  public id: string;
  @column()
  public skuId: string;
  @column()
  public skuName: string;
  @column()
  public username: string;
  @column()
  public qty: number;
  @column()
  public price:number;
  @column.dateTime({ autoCreate: true })
  public createdAt: DateTime
  @column.dateTime({ autoCreate: true, autoUpdate: true })
  public updatedAt: DateTime
  @beforeCreate()
  public static assignUuid(deliver: Deliver) {
      deliver.id = uuid()
  }
}
